<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 * $Log$
 *
 */
set_time_limit(0);
include_once("../config.inc.php");

session_start();
include(__Language_Path."/selectlanguage_admin.php");
include(__Common_Path."/AllWeb.inc.php");

$arrPower = CheckUsePower("getallreport");
if($arrPower === false || $arrPower[1] == "")ErrMsgOutputHTML("Error", "", 1);
$arrP1 = explode("@", $arrPower[1]);
$arrP2 = explode("#", $arrP1[1]);

if(empty($_data["GameDate"]))$_data["GameDate"] = date("Y-m-d");
if(empty($_data["GameTime1"]))$_data["GameTime1"] = "00:00:00";
if(empty($_data["GameTime2"]))$_data["GameTime2"] = "24:00:00";
$arrWeb = array();
if(sizeof($arrP2) > 0){
	foreach($_arrWeb as $key => $arrV){
		if(!in_array((int)$arrV[2], $arrP2))continue;
		$arrWeb[] = $arrV[0];
	}
}


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://192.168.5.20/crontab/getReport.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "GameDate=".$_data["GameDate"]."&GameTime1=".$_data["GameTime1"]."&GameTime2=".$_data["GameTime2"]."&AllWeb=".join(",", $arrWeb));
$ret = curl_exec ($ch);
curl_close ($ch);

foreach($_arrWeb as $key => $arrV){
	$ret = str_replace("{".$arrV[0]."}", $arrV[1], $ret);
}

writeFile(__Root_Path."/tmp/Report.txt", $ret, "w");


$arrTTT = array("ccc" => 9898798, "dddd" => 1098475984375);
print_r($arrTTT);
sort($arrTTT);
print_r($arrTTT);
?><!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Report </title>
<style>
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-size: 12px
	font-family: Arial, Helvetica, Verdana, Geneva,  sans-serif;
	background-color: #EFFFDF;
}
td {
	font-size: 12px
	font-family: Arial, Helvetica, Verdana, Geneva,  sans-serif;
	background-color: #FFFFFF;
	text-align: center;
}
.showTable {
	background-color: #9DBAD8;
	border: 1px solid #056FD8;
}
.web-td {
	text-align: right;
	padding-right: 2px;
}
.web-name {
	text-align: left;
	padding-left: 2px;
}
//-->
</style>
<script language="JavaScript">
<!--
function DDclick(strID){
	//alert(window.event.SrcElement.ID);
	document.all.tdcEmployees.sort = "-" + strID;
	document.all.tdcEmployees.reset();//             '不要忘記reset()
}
function DDDBlclick(strID){
	tdcEmployees.sort = strID;//window.event.SrcElement.ID;
	tdcEmployees.reset();
}
//-->
</script>
</head>

<body>
<form action="<?php print $_SERVER["PHP_SELF"];?>" name="ReportFrm">
報表日期：<input type="text" name="GameDate" value="<?php print $_data["GameDate"];?>" size="10"><br />
下注時間：<input type="text" name="GameTime1" value="<?php print $_data["GameTime1"];?>" size="10">~
<input type="text" name="GameTime2" value="<?php print $_data["GameTime2"];?>" size="10">
<input type="button" value="更新" onclick="document.ReportFrm.submit()">
</form>

<OBJECT ID="tdcEmployees" WIDTH=0 HEIGHT=0 CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83" >
  <PARAM NAME="TextQualifier" VALUE="%">
  <PARAM NAME="FieldDelim" VALUE="|">
  <PARAM NAME="DataURL" VALUE="/tmp/Report.txt">
  <PARAM NAME="UseHeader" VALUE="true">
</OBJECT>

<table  border="0" cellspacing="1" cellpadding="0" class="showTable" DATASRC="#tdcEmployees">
<thead>
<tr>
	<td id="SortNo" width="50" onclick="DDclick(this.id)" ondblclick="DDDBlclick(this.id)">序號</td>
	<td id="Web" width="150" onclick="DDclick(this.id)" ondblclick="DDDBlclick(this.id)">網站</td>
	<td id="WNo" width="120" onclick="DDclick(this.id)" ondblclick="DDDBlclick(this.id)">注單數</td>
	<td id="WGold" width="120" onclick="DDclick(this.id)" ondblclick="DDDBlclick(this.id)">總金額</td>
	<td id="WDGold" width="120" onclick="DDclick(this.id)" ondblclick="DDDBlclick(this.id)">總監結果</td>
</tr>
</thead>

<tbody>
<tr>
   <td><span datafld="SortNo"></span></td>
   <td><span datafld="Web"></span></td>
   <td><span datafld="WNo"></span></td>
   <td><span datafld="WGold"></span></td>
   <td><span datafld="WDGold"></span></td>
</tr> 
</tbody>

</table>
報表日期：<?php print $GameDate;?><br />
現在時間：<?php print date("Y-m-d H:i:s");?><br /><br />
</body>
</html>